<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title th:text="${sectionName}">个人中心</title>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/community.css">
    <link rel="stylesheet" href="/css/bootstrap-theme.min.css">
    <script src="/js/jquery-3.4.1.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/editormd.min.css">
    <link rel="stylesheet" href="/css/editormd.preview.min.css">

    <link href="/css/bootsnav.css" rel="stylesheet">
    <link href="/css/color.css" rel="stylesheet">
    <script src="/js/bootsnav.js"></script>
</head>
<body>
<div th:insert="~{navigation :: nav}"></div>

<div class="container-fluid main profile" style="border-radius:10px; box-shadow:0px 0px 16px 5px #ccc; margin-top: 20px;">
    <div class="row">
        <div class="col-lg-9 col-md-12 col-sm-12 col-xs-12">
            <h2><span th:text="${sectionName}"></span></h2>
            <hr>
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" th:if="${section == 'questions'}">
                <div class="media" th:each="question : ${pageInfo.list}" >
                    <div class="media-left">
                        <a href="#">
                            <!--<img class="media-object img-rounded" th:src="${question.user.headImg}">-->
                            <img class="media-object img-rounded" th:src="${question.headImg}">
                        </a>
                    </div>
                    <div class="media-body" style="padding-left: 20px;">
                        <h4 class="media-heading" >
                            <a th:href="@{'/question/'+${question.id}}" th:text="${question.title}" style="color: #333"></a>
                        </h4>
                        <span class="text-desc"><span th:text="${question.commentCount}"></span> 个回复 • <span
                                th:text="${question.viewCount}"></span> 次浏览 • <span
                                th:text="${#dates.format(question.gmtCreate,'yyyy-MM-dd HH:mm')}"></span></span>


                        <a th:href="@{'/publish/'+${question.id}}" class="community-menu"
                           th:if="${session.user != null && session.user.id == question.creator}">
                            <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                            编辑
                        </a>
                    </div>
                </div>
            </div>


            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" th:if="${section == 'replies'}">
                <div class="media" th:each="notification : ${pageInfo.list}">
                    <div class="media-body">
                        <p class="media-heading">
                            <span th:text="${notification.notifierName +' ' + notification.typeName + ' '}"></span>
                            <a th:href="@{'/notification/'+ ${notification.id}}"
                               th:text="${notification.outerTitle}">
                            </a>
                            <span class="label label-danger" th:if="${notification.status == 0}">未读</span>
                        </p>
                    </div>
                </div>
            </div>
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" th:if="${section == 'collects'}">
                <div class="media" th:each="question : ${pageInfo.list}">
                    <div class="media-left">
                        <a href="#">
                            <!--<img class="media-object img-rounded" th:src="${question.user.headImg}">-->
                            <img class="media-object img-rounded" th:src="${question.headImg}">
                        </a>
                    </div>
                    <div class="media-body" style="padding-left: 20px; width: 80%;">
                        <h4 class="media-heading" >
                            <a th:href="@{'/question/'+${question.id}}" th:text="${question.title}"></a>
                        </h4>
                        <span class="text-desc"><span th:text="${question.commentCount}"></span> 个回复 • <span
                                th:text="${question.viewCount}"></span> 次浏览 • <span
                                th:text="${#dates.format(question.gmtCreate,'yyyy-MM-dd HH:mm')}"></span></span>
                        <button th:value="${question.collectId}" class="btn btn-default btn-sm"  onclick="delCollect(this)">
                            <span class="glyphicon glyphicon-calendar" aria-hidden="true"></span>
                            取消收藏
                        </button>
                        <p th:if="${question.id == null}">该问题已被删除</p>
                    </div>
                    <div class="media-right" style="padding-right: 40px; margin-right: 40px;">
                        <!--<div th:text="${question}"></div>-->
                        <div th:text="收藏于+${#dates.format(question.gmtCreate2,'yyyy-MM-dd HH:mm')}"></div>
                    </div>
                </div>
            </div>




            <nav aria-label="Page navigation">
                <ul class="pagination">
                    <!--当前页数是否是首页，如果不是则出现首页标志-->
                    <li th:if="${!pageInfo.isFirstPage}">
                        <a th:href="@{'/profile/'+${section}}" aria-label="Previous">
                            <span aria-hidden="true">首页</span>
                        </a>
                    </li>
                    <!--当前页数是否还有上一页，如果不是则出现上一页标志-->
                    <li th:if="${pageInfo.hasPreviousPage}">
                        <a th:href="@{'/profile/'+${section}(page=${pageInfo.pageNum - 1})}" aria-label="Previous">
                            <span aria-hidden="true">&lt;</span>
                        </a>
                    </li>

                    <!--循环展示页数-->
                    <li th:each="navigatepageNum : ${pageInfo.navigatepageNums}" th:class="${navigatepageNum == pageInfo.pageNum} ? 'active' : ''">
                        <a th:text="${navigatepageNum}"
                           th:href="@{'/profile/'+${section}(page=${navigatepageNum})}">
                        </a>
                    </li>

                    <!--当前页数是否还有下一页，如果不是则出现下一页标志-->
                    <li th:if="${pageInfo.hasNextPage}">
                        <a th:href="@{'/profile/'+${section}(page=${pageInfo.pageNum + 1})}" aria-label="Next">
                            <span aria-hidden="true">&gt;</span>
                        </a>
                    </li>
                    <!--当前页数是否是尾页，如果不是则出现尾页标志-->
                    <li th:if="${!pageInfo.isLastPage}">
                        <a aria-label="Previous" th:href="@{'/profile/'+${section}(page=${pageInfo.pages})}">
                            <span aria-hidden="true">尾页</span>
                        </a>
                    </li>
                </ul>
            </nav>
        </div>

        <div class="col-lg-3 col-md-12 col-sm-12 col-xs-12">
            <div class="list-group section">
                <a href="/profile/questions"
                   th:class="${section == 'questions'}? 'active list-group-item' : 'list-group-item'">我的问题</a>
                <a href="/profile/replies"
                   th:class="${section == 'replies'}? 'active list-group-item' : 'list-group-item'">
                    最新回复
                    <span class="badge" th:text="${session.unreadCount}"></span>
                </a>
                <a href="/profile/collects"
                   th:class="${section == 'collects'}? 'active list-group-item' : 'list-group-item'">我的收藏</a>
            </div>
        </div>
    </div>
</div>
<div th:insert="~{footer :: foot}"></div>

</body>
<script>
    function delCollect(obj) {
        $(obj).parent().parent().fadeTo("slow", 0.1, function(){//fade
            $(obj).parent().parent().slideUp("slow", function() {//slide up
                $(obj).parent().parent().remove();//then remove from the DOM
            });
        });

        $.ajax({
            url : "/delCollect/"+$(obj).val(),
            type : "GET",
            success : function (msg) {
                console.log(msg)
            }
        })
    }
</script>
<script>
    !
        function() {
            function n(n, e, t) {
                return n.getAttribute(e) || t
            }
            function e(n) {
                return document.getElementsByTagName(n)
            }
            function t() {
                var t = e("script"),
                    o = t.length,
                    i = t[o - 1];
                return {
                    l: o,
                    z: n(i, "zIndex", -1),
                    o: n(i, "opacity", .5),
                    c: n(i, "color", "0,0,0"),
                    n: n(i, "count", 99)
                }
            }
            function o() {
                a = m.width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,
                    c = m.height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
            }
            function i() {
                r.clearRect(0, 0, a, c);
                var n, e, t, o, m, l;
                s.forEach(function(i, x) {
                    for (i.x += i.xa, i.y += i.ya, i.xa *= i.x > a || i.x < 0 ? -1 : 1, i.ya *= i.y > c || i.y < 0 ? -1 : 1, r.fillRect(i.x - .5, i.y - .5, 1, 1), e = x + 1; e < u.length; e++) n = u[e],
                    null !== n.x && null !== n.y && (o = i.x - n.x, m = i.y - n.y, l = o * o + m * m, l < n.max && (n === y && l >= n.max / 2 && (i.x -= .03 * o, i.y -= .03 * m), t = (n.max - l) / n.max, r.beginPath(), r.lineWidth = t / 2, r.strokeStyle = "rgba(" + d.c + "," + (t + .2) + ")", r.moveTo(i.x, i.y), r.lineTo(n.x, n.y), r.stroke()))
                }),
                    x(i)
            }
            var a, c, u, m = document.createElement("canvas"),
                d = t(),
                l = "c_n" + d.l,
                r = m.getContext("2d"),
                x = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame ||
                    function(n) {
                        window.setTimeout(n, 1e3 / 45)
                    },
                w = Math.random,
                y = {
                    x: null,
                    y: null,
                    max: 2e4
                };
            m.id = l,
                m.style.cssText = "position:fixed;top:0;left:0;z-index:" + d.z + ";opacity:" + d.o,
                e("body")[0].appendChild(m),
                o(),
                window.onresize = o,
                window.onmousemove = function(n) {
                    n = n || window.event,
                        y.x = n.clientX,
                        y.y = n.clientY
                },
                window.onmouseout = function() {
                    y.x = null,
                        y.y = null
                };
            for (var s = [], f = 0; d.n > f; f++) {
                var h = w() * a,
                    g = w() * c,
                    v = 2 * w() - 1,
                    p = 2 * w() - 1;
                s.push({
                    x: h,
                    y: g,
                    xa: v,
                    ya: p,
                    max: 6e3
                })
            }
            u = s.concat([y]),
                setTimeout(function() {
                        i()
                    },
                    100)
        } ();
</script>
</html>